package retu;

import leave.LeaveStudent;
import leave.StudentList;
import shisheng.Student;

import java.util.Scanner;

public class ConsentOperation implements IOperation{

    @Override
    public void work(StudentList studentList) {
        System.out.print("请输入学生的姓名:>");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int size = studentList.getUseSize();
        for (int i = 0; i < size; i++) {
            LeaveStudent leaveStudent = studentList.getLeaveStudents(i);
            if (name.equals(leaveStudent.getName())) {
                leaveStudent.setLeave(true);
                System.out.println("同意离校");
                return;
            }
        }
        System.out.println("没有此学生");
    }

}
